package acwing_01;
import java.io.*;
import java.util.*;
public class _798_差分_差分矩阵_视频写法 {
	static int N = 1010;
	static int n,m,q;
	static int arr[][] = new int[N][N];
	static int d[][] = new int[N][N];
	static int x1,y1,x2,y2,c;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		q = Integer.parseInt(st.nextToken());
		
		for(int i = 1; i <= n; i++) {
			st = new StringTokenizer(br.readLine());
			for(int j = 1; j <= m; j++) {
				arr[i][j] = Integer.parseInt(st.nextToken());
				insert(i,j,i,j,arr[i][j]);
			}
		}
		
		
		for(int i = 0; i < q; i++) {
			st = new StringTokenizer(br.readLine());
			x1 = Integer.parseInt(st.nextToken());
			y1 = Integer.parseInt(st.nextToken());
			x2 = Integer.parseInt(st.nextToken());
			y2 = Integer.parseInt(st.nextToken());
			c = Integer.parseInt(st.nextToken());
			insert(x1,y1,x2,y2,c);
		}
		
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= m; j++) {
				arr[i][j] = arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1] + d[i][j];
				bw.write(arr[i][j] + " ");
			}
			bw.newLine();
		}
		
		bw.flush();
		br.close();
		bw.close();
	}
	
	public static void insert(int x1,int y1,int x2,int y2,int c) {
		
		d[x1][y1] += c;
		d[x2 + 1][y1] -= c;
		d[x1][y2 + 1] -= c;
		d[x2 + 1][y2 + 1] += c;
		
	}
}
